package com.esa.servlet.choice;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.esa.dbi.impl.ChoiceDBImpl;
import com.esa.dbi.impl.CourseDBImpl;
import com.esa.dbi.impl.StudentDBImpl;
import com.esa.javabean.Choice;
import com.esa.javabean.Course;
import com.esa.javabean.Student;
import com.esa.javabean.StudentScore;

public class ShowChoiceDetailServlet extends HttpServlet {
	public void doGet(HttpServletRequest request,HttpServletResponse response)
	throws ServletException,IOException{
		response.setContentType("text/html");
		PrintWriter out=response.getWriter();
		this.doPost(request, response);
		out.flush();
		out.close();
	}
	
	public void doPost(HttpServletRequest request,HttpServletResponse response)
	throws ServletException,IOException{
		response.setContentType("text/html");
		PrintWriter out=response.getWriter();
		
		Course course=new Course();
		CourseDBImpl c=new CourseDBImpl();
		
		ChoiceDBImpl cdbi=new ChoiceDBImpl();
		List<StudentScore> all=new ArrayList<StudentScore>();
	

		String cno=request.getParameter("cno");
		course=c.getCourseByCno(cno);
		all=cdbi.getChoiceOfCno(cno);
		//int totalcount=all.size();
		
		String acname=(String)request.getSession().getAttribute("acname");
		request.setAttribute("acname",acname);
		request.setAttribute("list",all);
		request.setAttribute("course",course);
		//request.setAttribute("totalcount",totalcount);
		//request.setCharacterEncoding("utf-8");
		request.getRequestDispatcher("showChoiceDetail.jsp").forward(request, response);
		
		out.flush();
		out.close();
		
    }
}
